import { JobOrderService } from 'src/app/@core/services/jobOrder/job-order.service';
import { JobOrderProcess } from 'src/app/@core/data/job';
import { Component, Input } from '@angular/core';
import { TableWidthConfig } from 'ng-devui';
import { StorehouseService } from 'src/app/@core/services/storehouse/storehouse.service';
@Component({
  selector: 'app-report-histories',
  templateUrl: './report-histories.component.html',
  styleUrls: ['./report-histories.component.scss']
})
export class ReportHistoriesComponent {
  @Input() data: any;
  isSelected = false;
  displayTableData: any[] = [];
  tableheight = '230px';
  selectData:any;
  searchName:''
  pager = {
    total: 20,
    pageIndex: 1,
    pageSize: 20
  };
  pageSizeOptions = [10, 20, 30, 50, 100];
  dataTableOptions = {
    columns: [
      {
        field:'radio',
        header:'工单号',
        fieldType:'radio',
        fixedLeft:'0px'
      },
      {
        field: 'type',
        header: '物料编码',
        fieldType: 'text',
        fixedLeft:'100px'
      },
      {
        field: 'type',
        header: '物料名称',
        fieldType: 'text',
        fixedLeft:'200px'
      },
      {
        field: 'type',
        header: '规格',
        fieldType: 'text'
      },
      {
        field: 'type',
        header: '工序',
        fieldType: 'text'
      },
      {
        field: 'type',
        header: '报工数量',
        fieldType: 'text'
      },
      {
        field: 'type',
        header: '合格数',
        fieldType: 'text'
      },
      {
        field: 'type',
        header: '不合格数',
        fieldType: 'text'
      },
      {
        field: 'type',
        header: '报废数',
        fieldType: 'text'
      },
      {
        field: 'type',
        header: '报工人',
        fieldType: 'text'
      },
      {
        field: 'type',
        header: '开工时间',
        fieldType: 'text'
      },
      {
        field: 'type',
        header: '报工时间',
        fieldType: 'text'
      },
      {
        field: 'type',
        header: '备注',
        fieldType: 'text'
      },
      // {
      //   field: 'type',
      //   header: '审核人',
      //   fieldType: 'text'
      // },
      // {
      //   field: 'type',
      //   header: '审核时间',
      //   fieldType: 'text'
      // },
      // {
      //   field: 'type',
      //   header: '审核结果',
      //   fieldType: 'text'
      // },
      // {
      //   field: 'type',
      //   header: '审核备注',
      //   fieldType: 'text'
      // },
    ]
  };
  tableWidthConfig: TableWidthConfig[] = [
    {
      field: '工单号',
      width: '150px'
    },
    {
      field: '物料编码',
      width: '100px'
    },
    {
      field: '物料名称',
      width: '100px'
    },
    {
      field: '规格',
      width: '100px'
    },
    {
      field: '工序',
      width: '100px'
    },
    {
      field: '报工数量',
      width: '100px'
    },
    {
      field: '合格数',
      width: '100px'
    },
    {
      field: '不合格数',
      width: '100px'
    },
    {
      field: '报废数',
      width: '100px'
    },
    {
      field: '报工人',
      width: '100px'
    },
    {
      field: '开工时间',
      width: '150px'
    },
    {
      field: '报工时间',
      width: '150px'
    },
    {
      field: '备注',
      width: '100px'
    },
  ]
  filter = {
    EmployeeCodeName: '',
    ProductionNum: '',
    ProductionName: '',
    JobOrderNum: '',
    StartTime: '',
    EndTime: '',
    ProcessNum: '',
    ProcessName: '',
    PageNumber: 1,
    PageSize: 10
  };
  constructor(private StorehouseService:StorehouseService,private JobOrderService:JobOrderService) { }
  ngOnInit(): void {
    this.filter = this.data.data
    this.JobOrderService.GetReportProcessHistoriesByFilter(this.filter).subscribe((data:any)=>{
      this.displayTableData = data.items
      this.pager.total = data.totalCount
    })
  }
  radio(event: any,rowItem:any){
    if(event.target.checked){
      this.isSelected = true;
      this.selectData = rowItem
    }
  }
  pageIndexChange($event: any) {
    this.filter.PageNumber = $event
    this.JobOrderService.GetReportProcessHistoriesByFilter(this.filter).subscribe((data:any)=>{
      this.displayTableData = data.items
      this.pager.total = data.totalCount
    })
  }//切换页码
  pageSizeChange($event: any){
    this.filter.PageSize = $event
    this.JobOrderService.GetReportProcessHistoriesByFilter(this.filter).subscribe((data:any)=>{
      this.displayTableData = data.items
      this.pager.total = data.totalCount
    })
  }//改变每页显示数量
  search(){
    this.JobOrderService.GetReportProcessHistoriesByFilter(this.filter).subscribe((data:any)=>{
      this.displayTableData = data.items
      this.pager.total = data.totalCount
    })
  }
  reset(){
    this.filter = {
      EmployeeCodeName: '',
      ProductionNum: '',
      ProductionName: '',
      JobOrderNum: '',
      StartTime: '',
      EndTime: '',
      ProcessNum: '',
      ProcessName: '',
      PageNumber: 1,
      PageSize: 20
    };
    this.JobOrderService.GetReportProcessHistoriesByFilter(this.filter).subscribe((data:any)=>{
      this.displayTableData = data.items
      this.pager.total = data.totalCount
    })
  }
}
